import { observable, action } from "mobx";
import net from "../services/net";
import { Object } from "core-js";

export default class Store {
	@observable list = [];
  @observable pageNumber = 1;
  @observable pageCount= 10;

	@action 
	getList = async (params = {}) => {
		let url = "https://testapi.justdodo.cn/api/houses?";
		Object.keys(params).forEach((key, i) => {
			if(i !== 0) {
				url += "&";
			}
			url += `${key}=${params[key]}`;
		});
		const result = await net.get(url);
		if(result && result.code === 1) {
			this.list = result.data.list;
			this.pageNumber = result.data.pageNumber;
			this.pageNumber = result.data.pageCount;
			return result.data;
		}
		return {};
	}
}